#include <iostream>
#include<stack>
#include<queue>
#include<string>
#include<vector>
#include<deque>
#include<utility>
#include<map>
#include<algorithm>
using namespace std;
class mycomparison {
public:
    bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs) {
        return lhs.second < rhs.second;
    }
};
class Solution {
public:
    vector<int> topKFrequent(vector<int>& nums, int k) {
        map<int, int> maps;
        for (auto var : nums)
        {
            maps[var]++;
        }
        priority_queue<pair<int, int>, vector<pair<int, int>>, mycomparison> pri_que;
        for (auto it = maps.begin(); it != maps.end(); it++)
        {
            pri_que.push(*it);
        }

        vector<int> result(k);
        for (int i = 0; i < k; i++)
        {
            result[i] = pri_que.top().first;
            pri_que.pop();
        }
        return result;
    }
};

int main()
{
    Solution so;
    vector<int> nums{ 1,1,1,2,2,3 };
    so.topKFrequent(nums, 2);
    return 0;
}